package ge.unihack.instantdj;

import ge.unihack.instantdj.utils.GIFView;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class SplashScreenActivity extends Activity{
	
	private static final String TAG = SplashScreenActivity.class.getSimpleName();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		startActivity(new Intent(this, MainActivity.class));
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        		WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        setContentView(R.layout.activity_splash_screen);
        
        GIFView view = (GIFView) findViewById(R.id.splashView);
        view.setResource("file:///android_asset/splash_screen.gif");
        
		
		new RequestServe().execute();
	}
	
	private class RequestServe extends AsyncTask<Void, Void, Void> {
		
		@Override
		protected void onPreExecute() {
			super.onPreExecute();
		}

		@Override
		protected Void doInBackground(Void... params) {
			// TODO
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				throw new RuntimeException(e);
			}
			
			return null;
		}	
		
		@Override
		protected void onPostExecute(Void result) {
			super.onPostExecute(result);
			
			Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
			startActivity(intent);
			finish();
		}
	}
}
